## setup ##

# clean environment
rm(list=ls())

# load data
dat <- read.csv2("data_experiment_covariates_csv.csv",
                 encoding = 'UTF-8')


## table with means of pre-treatment covariates by treatment condition ##

# define variables
vars <- c("east", "migrant", "female", "age", "day")

# get means
means <- sapply(vars, function(x) cbind(tapply(dat[,x], dat$immback, mean, na.rm=T), tapply(dat[,x], dat$partisan, mean, na.rm=T)))
means <- t(means)
means <- round(means, 2)
colnames(means) <- c("no immigrant background", "immigrant background", "no partisan", "partisan")

# show final table
means
